/*
 * Copyright 2013 Kenneth Syharath
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the license at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the license is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the license for specific language governing
 * permissions and limitations under the license.
 */

package test_output;

import java.util.List;
import java.util.concurrent.Callable;

import randomness_measurement.ShiftMeasurements;
import shuffler_classes.Shufflers;

import com.google.common.collect.Lists;

public class AverageShiftOutput {
	public static final long constantOfRobustness = 1000000;
	
	public static void main(String args[]) {
		List startList = Lists.newArrayList();
		List endList;
		
		for (int i = 1; i <= 60; i++)
			startList.add(i);
		
		System.out.println("Start List");
		for (Object obj : startList)
			System.out.print(obj + ", ");
		System.out.println();
		
		System.out.println("Expected Shift: " 
				+ ShiftMeasurements.calcExpectedShift(startList));
		
		{
			long sumOverallShift = 0;
			
			for (int i = 0; i < constantOfRobustness; i++) {
				endList = Shufflers.fisherYatesShuffle(Lists.newArrayList(startList));
				sumOverallShift += ShiftMeasurements.measureOverallShift(startList, endList);
			}
			
			double avgOverallShift = sumOverallShift / constantOfRobustness;
			
			System.out.println("Fisher Yates Experimental " +
					"Average Overall Shift: " + avgOverallShift);
		}
		
		{
			long sumOverallShift = 0;
			
			for (int i = 0; i < constantOfRobustness; i++) {
				endList = Shufflers.riffleShuffle(Lists.newArrayList(startList), 2, false);
				sumOverallShift += ShiftMeasurements.measureOverallShift(startList, endList);
			}
			
			double avgOverallShift = sumOverallShift / constantOfRobustness;
			
			System.out.println("Standard Riffle Experimental " +
					"Average Overall Shift: " + avgOverallShift);
		}
		
		{
			long sumOverallShift = 0;
			
			for (int i = 0; i < constantOfRobustness; i++) {
				endList = Shufflers.riffleShuffle(Lists.newArrayList(startList), 2, true);
				sumOverallShift += ShiftMeasurements.measureOverallShift(startList, endList);
			}
			
			double avgOverallShift = sumOverallShift / constantOfRobustness;
			
			System.out.println("Bot-Favor Riffle Experimental " +
					"Average Overall Shift: " + avgOverallShift);
		}
		
		{
			long sumOverallShift = 0;
			
			for (int i = 0; i < constantOfRobustness; i++) {
				endList = Shufflers.pileShuffle(startList, 5, 0, false);
				sumOverallShift += ShiftMeasurements.measureOverallShift(startList, endList);
			}
			
			double avgOverallShift = sumOverallShift / constantOfRobustness;
			
			System.out.println("Standard Pile-5 Experimental " +
					"Average Overall Shift: " + avgOverallShift);
		}
		
		{
			long sumOverallShift = 0;
			
			for (int i = 0; i < constantOfRobustness; i++) {
				endList = Shufflers.pileShuffle(startList, 5, 0, true);
				sumOverallShift += ShiftMeasurements.measureOverallShift(startList, endList);
			}
			
			double avgOverallShift = sumOverallShift / constantOfRobustness;
			
			System.out.println("Random Pile-5 Experimental " +
					"Average Overall Shift: " + avgOverallShift);
		}
		
		{
			long sumOverallShift = 0;
			
			for (int i = 0; i < constantOfRobustness; i++) {
				endList = Shufflers.pileShuffle(startList, 5, 3, false);
				sumOverallShift += ShiftMeasurements.measureOverallShift(startList, endList);
			}
			
			double avgOverallShift = sumOverallShift / constantOfRobustness;
			
			System.out.println("Cascade-3 Pile-5 Experimental " +
					"Average Overall Shift: " + avgOverallShift);
		}
		
		{
			long sumOverallShift = 0;
			
			for (int i = 0; i < constantOfRobustness; i++) {
				endList = Shufflers.pileShuffle(startList, 5, 3, true);
				sumOverallShift += ShiftMeasurements.measureOverallShift(startList, endList);
			}
			
			double avgOverallShift = sumOverallShift / constantOfRobustness;
			
			System.out.println("Random Cascade-3 Pile-5 Experimental " +
					"Average Overall Shift: " + avgOverallShift);
		}
		
		{
			long sumOverallShift = 0;
			
			for (int i = 0; i < constantOfRobustness; i++) {
				endList = Shufflers.mongeanShuffle(startList);
				sumOverallShift += ShiftMeasurements.measureOverallShift(startList, endList);
			}
			
			double avgOverallShift = sumOverallShift / constantOfRobustness;
			
			System.out.println("Mongean Experimental " +
					"Average Overall Shift: " + avgOverallShift);
		}
		
		{
			long sumOverallShift = 0;
			
			for (int i = 0; i < constantOfRobustness; i++) {
				endList = Shufflers.stripShuffle(startList, 0.25, 0.5, 0);
				sumOverallShift += ShiftMeasurements.measureOverallShift(startList, endList);
			}
			
			double avgOverallShift = sumOverallShift / constantOfRobustness;
			
			System.out.println("Standard Strip Experimental " +
					"Average Overall Shift: " + avgOverallShift);
		}
		
		{
			long sumOverallShift = 0;
			
			for (int i = 0; i < constantOfRobustness; i++) {
				endList = Shufflers.stripShuffle(startList, 0.25, 0.5, 3);
				sumOverallShift += ShiftMeasurements.measureOverallShift(startList, endList);
			}
			
			double avgOverallShift = sumOverallShift / constantOfRobustness;
			
			System.out.println("Cascade-3 Strip Experimental " +
					"Average Overall Shift: " + avgOverallShift);
		}
	}
}
